import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  unistorage: true,
  state: (): {
    user: IUser
  } => {
    return {
      user: {
        id: 0,
        name: '',
        phone: '',
        email: '',
        avatar: '',
        birthday: '',
        password: '',
        is_disabled: 0,
        house_id: null,
        parking_id: null,
        created_at: ''
      }
    }
  },
  getters: {
    getUser(): IUser {
      return this.user
    }
  },
  actions: {
    setUser(user: IUser) {
      this.user = user
    },
    clearUser() {
      this.user = {
        id: 0,
        name: '',
        phone: '',
        email: '',
        birthday: '',
        password: '',
        is_disabled: 0,
        house_id: null,
        parking_id: null,
        created_at: ''
      }
    }
  }
})
